package inherit;

//父类、基类、超类
class Animal{
    public String name;
    public int age;
    private int weight; //私有的成员变量不能被继承

    public void eat(){
        System.out.println(name+"正在吃饭！");
    }
}

//子类、派生类 -- 一般情况继承不要超过3层
class Dog extends Animal{
    public void barks(){
        System.out.println(name+"汪汪叫！"+"年龄"+age);
    }
}

class Cat extends Animal{
    public void catchMouse(){
        System.out.println(name+"正在抓老鼠！");
    }
}

public class Test {
    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.name = "旺财";
        dog.age = 2;
        dog.barks();
        dog.eat();
    }
}
